package graph.chart;

import graph.Point;
import graph.chart.point.decorator.PointDecorator;

import java.awt.Graphics;
import java.awt.Graphics2D;


public class PointChart extends GenericChart{


	@Override
	public void paintChart(Graphics2D g2D){
		if(this.plotSet != null && plotSet.getPoints() != null && this.genericGraph != null){
			
			PointDecorator decorator = plotSet.getPointDecorator();
			
			for(Point point : plotSet.getPoints()){
				Point _point = genericGraph.pointToScreenCoordinates(point);
				
				if(decorator != null){
					decorator.decorate(g2D, _point);
				}else{
					g2D.drawLine((int)_point.getX(), (int)_point.getY(), (int)_point.getX(), (int)_point.getY());
				}
				
				if(plotSet.isxAxisMirrorEnabled()){
					Point point2 = new Point(point.getX(), -point.getY());
					_point = genericGraph.pointToScreenCoordinates(point2);
					if(decorator != null){
						decorator.decorate(g2D, _point);
					}else{
						g2D.drawLine((int)_point.getX(), (int)_point.getY(), (int)_point.getX(), (int)_point.getY());
					}
				}
			}
		}
	}
}
